package cn.dkdoo.blackhorse_transactional.mongo.api.controller;

import cn.dkdoo.blackhorse_transactional.mongo.api.bean.vo.TestRequest;
import cn.dkdoo.blackhorse_transactional.mongo.api.service.MongodbService;
import cn.dkdoo.utils.entity.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author nicky
 * @date 2021/5/12 下午5:23
 */
@RestController
@RequestMapping("/mongodb")
public class MongodbController {

    @Autowired
    private MongodbService mongodbService;

    @RequestMapping(value = "/addAndUpdate", method = RequestMethod.POST)
    public BaseResponse testAddAndUpdate(@RequestBody TestRequest request) {
        BaseResponse response = mongodbService.testAddAndUpdate(request);
        return response;
    }

    @RequestMapping(value = "/updateTwice", method = RequestMethod.POST)
    public BaseResponse testUpdateTwice(@RequestBody TestRequest request) {
        BaseResponse response = mongodbService.updateTwice(request);
        return response;
    }

}
